package com.dinggou.shopjb.adapters;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.dinggou.shopjb.R;
import com.dinggou.shopjb.base.BaseRVAdapter;
import com.dinggou.shopjb.base.BaseRVHolder;
import com.dinggou.shopjb.bean.WelfareTaskBean;

import java.util.List;

public class WelfareAdapter extends BaseRVAdapter {
    public WelfareAdapter(Context context, List list) {
        super(context, list);
    }

    @Override
    public int onCreateViewLayoutID(int viewType) {
        return R.layout.item_welfare;
    }

    @Override
    public void onBindView(BaseRVHolder holder, int position) {
        ImageView iconImg = holder.getViewHolder().get(R.id.welfare_item_icon);
        ImageView typeImg = holder.getViewHolder().get(R.id.welfare_task_type);
        TextView title_tv = holder.getViewHolder().get(R.id.welfare_item_title_text);
        TextView integral_tv = holder.getViewHolder().get(R.id.welfare_item_integral_text);
        TextView process_tv = holder.getViewHolder().get(R.id.welfare_item_process);
        WelfareTaskBean.DayBean dayBean = ( WelfareTaskBean.DayBean)mList.get(position);
        if(dayBean.getTaskStatus().equals("0")){
            typeImg.setImageResource(R.drawable.welfare_finish);
        }else if(dayBean.getTaskStatus().equals("1")){
            typeImg.setImageResource(R.drawable.welfare_pickup);
        } else if (dayBean.getTaskStatus().equals("2")) {
            typeImg.setImageResource(R.drawable.welfare_over);
        }
        title_tv.setText(dayBean.getTitle());
        integral_tv.setText("+"+dayBean.getReward()+"积分");
        process_tv.setText("进度: "+dayBean.getTaskProgress()+"/"+dayBean.getTarget());
        Glide.with(mContext).load(dayBean.getIcon()).into(iconImg);
    }
}
